<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('所有分润出款数据')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								<label style="width: 80px;">服务商编号：</label>
								<input type="text" name="agent_num"/>
							</li>
							<li>
								<label style="width: 80px;">服务商名称：</label>
								<input type="text" name="agent_name"/>
							</li>
							<li>
								<label style="width: 80px;">结算卡号：</label>
								<input type="text" name="screen_num"/>
							</li>
							<li>
								<label style="width: 80px">出款流水号：</label>
								<input type="text" name="settle_serial"/>
							</li>
							<li>
								<label style="width: 80px">唯一流水号：</label>
								<input type="text" name="settle_id"/>
							</li>
							<li>
								<label style="width: 80px;">结算类型：</label>
								<select name="profit_type" th:with="type=${@dict.getType('profit_type')}">
									<option value="">请选择</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li>
								<label style="width: 80px;">出款状态：</label>
								<select name="status">
									<option value="">请选择</option>
									<option value="1">出款成功</option>
									<option value="-2">出款失败</option>
									<option value="-3">冻结</option>
									<option value="0">待处理（默认）</option>
									<option value="-1">已上送</option>
								</select>
							</li>
							<li>
								<label style="width: 80px;">账户类型：</label>
								<select name="nature">
									<option value="">请选择</option>
									<option value="1">对公</option>
									<option value="2">对私</option>
								</select>
							</li>
							<li>
								<label style="width: 80px;">终端类型：</label>
								<select name="agent_type" th:with="type=${@dict.getType('terminal_type')}">
									<option value="">请选择</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>

							<li>
								<label style="width: 80px;">结算人名：</label>
								<input type="text" name="screen_name"/>
							</li>
							<li class="select-time">
								<label style="width: 80px;">交易日期：</label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="mindDate"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="maxDate"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="exportExcel()" shiro:hasPermission="agentInfo:profitSbOrder:export">
					<i class="fa fa-download"></i> 导出
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" class="table text-nowrap"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "agentInfo/profitSbOrder";
        var profitTypeDatas = [[${@dict.getType('profit_type')}]];
		var terminalTypeDatas = [[${@dict.getType('terminal_type')}]];



		$(function()  {
            var options = {
                url: prefix + "/payList",
				exportUrl: prefix + "/payExport",
				modalName: "分润出款明细",
				showSearch: false,
		        showRefresh: false,
		        showToggle: false,
		        showColumns: false,
	            clickToSelect:true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'SETTLE_SERIAL',
					title : '流水号',
					formatter:function (value, row, index) {
						return value+$.table.tooltip('[备注]'+row.NOTE,4);
					}
				},
				{
					field : 'SETTLE_ID',
					title : '唯一流水号'
				},
				{
					field : 'AGENT_NUM',
					title : '服务商编号'
				},
				{
					field : 'AGENT_NAME',
					title : '服务商名称',
					formatter:function (value, row, index) {
						return $.table.tooltip(value,4);
					}
				},
				{
					field : 'AUDITDATE',
					title : '生成日期'
				},
				{
					field : 'PROFIT_TYPE',
					title : '类型',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(profitTypeDatas, value);
					},
				},
				{
					field : 'CYCLE',
					title : '周期',
					formatter: function(value, row, index) {
						if ("0"==value){
							return '<span style="color:blue;">日返</span>';
						}else if("1"==value){
							return '<span style="color:green;">月返</span>';
						}else{
							return '<span style="color:red;">未知</span>';
						}
					}
				},
				{
					field : 'SCREEN_NAME',
					title : '结算人'
				},
				{
					field : 'BANK_NAME',
					title : '开户行名称'
				},
				{
					field : 'SHOW_SCREENNUM',
					title : '结算卡'
				},
				{
					field : 'PROFIT_BERFORTAX',
					title : '税前结算金额(元)',
					formatter: function(value, row, index) {
						return $.table.rmbFormatter(value);
					}
				},
				{
					field : 'TAX_MONEY',
					title : '税金(元)',
					formatter: function(value, row, index) {
						return $.table.rmbFormatter(value);
					}
				},
				{
					field : 'MONEY',
					title : '结算金额(元)',
					formatter: function(value, row, index) {
						return $.table.rmbFormatter(value);
					}
				},
				{
					field : 'PAY_TIME',
					title : '付款时间'
				},
				{
					field : 'AGENT_TYPE',
					title : '终端类型',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(terminalTypeDatas, value);
					}
				},
				{
					field : 'STATUS',
					title : '出款状态',
					formatter: function(value, row, index) {
						if ("0"==value){
							return '<span style="color:blue;">待处理</span>';
						}else if("1"==value){
							return '<span style="color:green;">出款成功</span>';
						}else if("-2"==value){
							return '<span style="color:#880000;">出款失败</span>';
						}else if("-3"==value){
							return '<span style="color:green;">冻结</span> ';
						}else if("-1"==value){
							return '<span style="color:green;">已上送</span>';
						}else{
							return '<span style="color:red;">出款失败</span>';
						}
					}
				},
				{
					field : 'PAYMENT_M',
					title : '扣款前分润金额（元）'
				},
				{
					field : 'PAYMENT_B',
					title : '扣款比例（%）（非实际占比）'
				},
				{
					field : 'PAYMENT_A',
					title : '扣款金额'
				},
				/*{
					field: 'YL_ID',
					title: '采购人奖励团长编号'
				},
				{
					field: 'YL_NAME',
					title: '采购人奖励团长名称'
				},
				{
					field: 'PRO_AGENT_NUM',
					title: '采购人奖励服务商编号'
				},
				{
					field: 'PRO_AGENT_NAME',
					title: '采购人奖励服务商名称'
				}*/]
            };
            $.table.init(options);
        });
		// 导出数据
		function exportExcel(formId) {
			table.set();
			$.modal.confirm("确定导出分润出款明细吗？", function() {
				var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
				var params = $("#" + table.options.id).bootstrapTable('getOptions');
				var dataParam = $("#" + currentId).serializeArray();
				dataParam.push({ "name": "orderByColumn", "value": params.sortName });
				dataParam.push({ "name": "isAsc", "value": params.sortOrder });
				$.modal.loading("正在导出数据，请稍后...");
				$.post(table.options.exportUrl, dataParam, function(result) {
					if (result.code == web_status.SUCCESS) {
						$.modal.alertSuccess(result.msg);
					} else if (result.code == web_status.WARNING) {
						$.modal.alertWarning(result.msg)
					} else {
						$.modal.alertError(result.msg);
					}
					$.modal.closeLoading();
				});
			});

		}
    </script>
</body>
</html>
